package com.code.leetcode.offer;

/**
 * @author codeDorado
 * @version 1.0
 * @date 2020/8/13 19:03
 */
public class The66 {
    public int[] constructArr(int[] a) {
        if (a == null || a.length == 0) return new int[0];
        int[] rtns = new int[a.length];
        int temp = 1;
        rtns[0] = 1;

        for (int i = 1; i < a.length; i++) {
            rtns[i] = rtns[i - 1] * a[i - 1];
        }

        for (int i = a.length - 2; i >= 0; i--) {
            temp *= a[i + 1];
            rtns[i] *= temp;
        }
        return rtns;
    }
}
